<template>
	<view class="wheel_list">
		<navBar title="抽奖记录" bg="#FFF"></navBar>

		<empty v-if="!list.length && total == 0"></empty>

		<view class="list">
			<view class="item flex_r_between" v-for="(item,index) in list" :key="index">
				<view class="left">
					<text>获得</text>
					<view>
						<uni-dateformat :date="item.create_time * 1000" format="yyyy.MM.dd hh:mm"></uni-dateformat>
					</view>
				</view>
				<view class="right">
					<view class="hidden">{{ item.prize_name }}</view>
				</view>
			</view>
			
			<view class="flex_r_around">
				<u-loading-icon :show="loading" mode="circle" color="#FD2A53"></u-loading-icon>
			</view>
		</view>


	</view>
</template>

<script>
	import navBar from '@/compentents/navBar/navBar.vue';
	import empty from '@/compentents/empty/empty.vue';
	import HevuLoading from '@/components/hevu-loading/hevu-loading.vue';
	export default {
		components: {
			navBar,
			empty,
			HevuLoading,
		},
		data() {
			return {
				// 记录
				page: 1,
				total: 1,
				list: [],
				
				loading: false,
			}
		},
		methods: {
			getLog() {
				this.loading = true;
				this.$get('/active.trafficPrizeV2/getMyPrizeLog', {
					page: this.page
				}).then(res => {
					this.loading = false;
					uni.stopPullDownRefresh();
					this.total = res.data.total;
					this.list.push(...res.data.data);
				})
			},
		},

		onLoad() {
			this.getLog();
		},

		onReachBottom() {
			if (this.total > this.list.length) {
				this.page++;
				this.getLog();
			}
		},

		onPullDownRefresh() {
			this.total = 1;
			this.page = 1;
			this.list = [];
			this.getLog();
		}
	}
</script>

<style lang="less" scoped>
	.wheel_list {
		padding: 0 48rpx 48rpx;
		min-height: 100vh;
		background: #FFF;
	}

	.list {
		overflow: hidden;
		.item {
			padding: 24rpx 0 26rpx;
			border-bottom: 2rpx solid #F1F1F1;
			overflow: hidden;

			.left {
				margin-bottom: 8rpx;

				text {
					font-weight: 500;
					font-size: 32rpx;
					color: #6B0217;
					line-height: 40rpx;
				}

				view {
					text {
						font-size: 28rpx;
						line-height: 40rpx;
					}
				}
			}

			.right {
				flex: 1;
				overflow: hidden;
				view {
					font-size: 26rpx;
					color: #3916F9;
					line-height: 36rpx;
					text-align: right;
				}
			}
		}
	}
</style>